//
//  QJMineOrderHeader.m
//  QuanJieShopProject
//
//  Created by 刘中义 on 2018/2/25.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "QJMineOrderHeader.h"

@implementation QJMineOrderHeader

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        self.orderTimeLabel = [[UILabel alloc]init];
        self.orderTimeLabel.text = @"订单状态";
        [self.orderTimeLabel sizeToFit];
        [self.contentView addSubview:self.orderTimeLabel];
        self.orderTimeLabel.font = [UIFont systemFontOfSize:14];
        self.orderTimeLabel.textColor = [UIColor orangeColor];
        self.orderTimeLabel.textAlignment = NSTextAlignmentRight;
        
        self.orderTitleLabel = [[UILabel alloc]init];;
        self.orderTitleLabel.text = @"订单号";
        [self.orderTitleLabel sizeToFit];
        [self.contentView addSubview:self.orderTitleLabel];
        self.orderTitleLabel.font = [UIFont systemFontOfSize:12];
        self.orderTitleLabel.textColor = HexRGB(0x333333);
        self.orderTitleLabel.textAlignment = NSTextAlignmentLeft;
        
        //约束
        [self.orderTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView.mas_top).offset(3*[UIScreen mainScreen].bounds.size.height / 667.0);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-3*[UIScreen mainScreen].bounds.size.height / 667.0);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-10*[UIScreen mainScreen].bounds.size.width / 375.0);
        }];
        
        [self.orderTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).offset(20*[UIScreen mainScreen].bounds.size.width / 375.0);
            make.top.mas_equalTo(self.contentView.mas_top).offset(3*[UIScreen mainScreen].bounds.size.height / 667.0);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-3*[UIScreen mainScreen].bounds.size.height / 667.0);
            make.right.mas_equalTo(self.orderTimeLabel.mas_left).offset(-5*[UIScreen mainScreen].bounds.size.width / 375.0);
        }];
        
    }
    return self;
}
-(void)headerUpdateModel:(MineOrderModel *)model{
    if (model) {
        self.orderTitleLabel.text = [NSString stringWithoutNilFormart:[NSString stringWithFormat:@"订单号:%@",model.order_nu]];
        NSString *statusStr = [NSString stringWithFormat:@"%@",model.status];
        NSString *orderStatus;
        if ([statusStr isEqualToString:@"1"]) {
            orderStatus = @"待付款";
        }else if ([statusStr isEqualToString:@"2"]){
            orderStatus = @"待发货";
        }else if ([statusStr isEqualToString:@"3"]){
            orderStatus = @"已发货";
        }else if ([statusStr isEqualToString:@"4"]){
            orderStatus = @"已完成";
        }
        self.orderTimeLabel.text = [NSString stringWithoutNilFormart:[NSString stringWithFormat:@"%@",orderStatus]];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
